home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / GENCSRC.ZIP / POINTER2.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  834b  |  27 lines

  1.                                          /* Chapter 8 - Program 2 */
  2. main()
  3. {
  4. char strg[40],*there,one,two;
  5. int *pt,list[100],index;
  6.  
  7.    strcpy(strg,"This is a character string.");
  8.  
  9.    one = strg[0];                    /* one and two are identical */
  10.    two = *strg;
  11.    printf("The first output is %c %c\n",one,two);
  12.  
  13.    one = strg[8];                   /* one and two are indentical */
  14.    two = *(strg+8);
  15.    printf("the second output is %c %c\n",one,two);
  16.  
  17.    there = strg+10;           /* strg+10 is identical to strg[10] */
  18.    printf("The third output is %c\n",strg[10]);
  19.    printf("The fourth output is %c\n",*there);
  20.  
  21.    for (index = 0;index < 100;index++)
  22.       list[index] = index + 100;
  23.    pt = list + 27;
  24.    printf("The fifth output is %d\n",list[27]);
  25.    printf("The sixth output is %d\n",*pt);
  26. }
  27.